var t = getApp(), e = t.requirejs("core"), a = t.requirejs("wxParse/wxParse"), i = t.requirejs("biz/diypage"), s = t.requirejs("jquery");

Page({
    data: {
        route: "member",
        icons: t.requirejs("icons"),
        member: {},
        diypages: {},
        audios: {},
        audiosObj: {},
        modelShow: !1,
        autoplay: !0,
        interval: 5e3,
        duration: 500,
        swiperheight: 0,
        iscycelbuy: !1,
        bargain: !1,
        result: {}
    },
    onLoad: function(t) {
        this.setData({
            options: t
        });
    },
    getInfo: function() {
        var i = this;
        e.get("member", {}, function(t) {
            console.log(t),
            getApp().setCache("umids", t.id)
            console.log(t.id);
            
            1 == t.isblack && wx.showModal({
                title: "无法访问",
                content: "您在商城的黑名单中，无权访问！",
                success: function(t) {
                    t.confirm && i.close(), t.cancel && i.close();
                }
            }), i.setData({
                member: t,
                show: !0,
                customer: t.customer,
                customercolor: t.customercolor || "",
                phone: t.phone,
                phonecolor: t.phonecolor || "",
                phonenumber: t.phonenumber || "",
                iscycelbuy: t.iscycelbuy,
                bargain: t.bargain
            }), t.error, a.wxParse("wxParseData", "html", t.copyright, i, "5");
        });
    },
    onShow: function() {
        var a = this;
        this.getInfo(), wx.getSystemInfo({
            success: function(t) {
                var e = t.windowWidth / 1.7;
                a.setData({
                    windowWidth: t.windowWidth,
                    windowHeight: t.windowHeight,
                    swiperheight: e
                });
            }
        }), a.setData({
            imgUrl: t.globalData.approot
        }), i.get(this, "member", function(t) {});
    },
    onShareAppMessage: function() {
        return e.onShareAppMessage();
    },
    imagesHeight: function(t) {
        var e = t.detail.width, a = t.detail.height, i = t.target.dataset.type, s = this;
        wx.getSystemInfo({
            success: function(t) {
                s.data.result[i] = t.windowWidth / e * a, (!s.data[i] || s.data[i] && result[i] < s.data[i]) && s.setData({
                    result: s.data.result
                });
            }
        });
    },
    cancelclick: function() {
        wx.switchTab({
            url: "/pages/index/index"
        });
    },
    confirmclick: function() {
        wx.openSetting({
            success: function(t) {}
        });
    },
    phone: function() {
        var t = this.data.phonenumber + "";
        wx.makePhoneCall({
            phoneNumber: t
        });
    },
    play: function(t) {
        var r = t.target.dataset.id, u = this.data.audiosObj[r] || !1;
        if (!u) {
            u = wx.createInnerAudioContext("audio_" + r);
            var e = this.data.audiosObj;
            e[r] = u, this.setData({
                audiosObj: e
            });
        }
        var c = this;
        u.onPlay(function() {
            var n = setInterval(function() {
                var t = u.currentTime / u.duration * 100 + "%", e = Math.floor(Math.ceil(u.currentTime) / 60), a = (Math.ceil(u.currentTime) % 60 / 100).toFixed(2).slice(-2), i = Math.ceil(u.currentTime);
                e < 10 && (e = "0" + e);
                var s = e + ":" + a, o = c.data.audios;
                o[r].audiowidth = t, o[r].Time = n, o[r].audiotime = s, o[r].seconds = i, c.setData({
                    audios: o
                });
            }, 1e3);
        });
        var a = t.currentTarget.dataset.audio, i = t.currentTarget.dataset.time, s = t.currentTarget.dataset.pausestop, o = t.currentTarget.dataset.loopplay;
        0 == o && u.onEnded(function(t) {
            n[r].status = !1, c.setData({
                audios: n
            });
        });
        var n = c.data.audios;
        n[r] || (n[r] = {}), u.paused && 0 == i ? (u.src = a, u.play(), 1 == o && (u.loop = !0), 
        n[r].status = !0, c.pauseOther(r)) : u.paused && 0 < i ? (u.play(), 0 == s ? u.seek(i) : u.seek(0), 
        n[r].status = !0, c.pauseOther(r)) : (u.pause(), n[r].status = !1), c.setData({
            audios: n
        });
    },
    pauseOther: function(i) {
        var o = this;
        s.each(this.data.audiosObj, function(t, e) {
            if (t != i) {
                e.pause();
                var a = o.data.audios;
                a[t] && (a[t].status = !1, o.setData({
                    audios: a
                }));
            }
        });
    },
    onHide: function() {
        this.pauseOther();
    },
    onUnload: function() {
        this.pauseOther();
    },
    navigate: function(t) {
        var e = t.currentTarget.dataset.url, a = t.currentTarget.dataset.phone, i = t.currentTarget.dataset.appid, s = t.currentTarget.dataset.appurl;
        e && wx.navigateTo({
            url: e,
            fail: function() {
                wx.switchTab({
                    url: e
                });
            }
        }), a && wx.makePhoneCall({
            phoneNumber: a
        }), i && wx.navigateToMiniProgram({
            appId: i,
            path: s
        });
    },
    close: function() {
        t.globalDataClose.flag = !0, wx.reLaunch({
            url: "/pages/index/index"
        });
    }
});